def ispal(num):
    if str(num) == str(num)[::-1]:
        return True
    else:
        return False

l = 0

for x in range(1,10000+1):
    num = x
    for y in range(50):
        num = num + int(str(num)[::-1])
        if ispal(num):
            l += 1
            break

print(10000-l)